import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Map {
    //读取地图，，并且把他存入一个2为数组里面
    public List list=new ArrayList<>();
    public String[][] Map=null;
    BufferedReader bufferedReader;
   public String[][] DuQuMap(){
       try {
           bufferedReader=new BufferedReader(new FileReader("image/map.txt"));
           String s=null;
           while ((s=bufferedReader.readLine())!=null){
               System.out.println(s);
                list.add(s);
           }
           System.out.println(list.size());
                int row=list.size();
                int cloum=0;
           for (int i = 0; i < list.size(); i++) {
               String str=(String) list.get(i);
               String[] str1=str.split(",");
               cloum=str1.length;

           }
           Map=new String[row][cloum];
           for (int i = 0; i < list.size(); i++) {
               String str=(String) list.get(i);
               String[] str1=str.split(",");
               for (int j = 0; j < str1.length; j++) {
                   Map[i][j]=str1[j];
               }
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
       finally {
           if (bufferedReader==null){
               try {
                   bufferedReader.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
       }
       return Map;
   }
}
